/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://github.com/mineadmin
 */

import type { MaSearchItem } from "@mineadmin/search";
import MaRemoteSelect from "@/components/ma-remote-select/index.vue";
import { pageAll as getVideoTypeList } from "$/gq/video-monitoring/api/gqVideoType.ts";
import MaDictSelect from "@/components/ma-dict-picker/ma-dict-select.vue";

export default function getSearchItems(t: any): MaSearchItem[] {
  return [
    {
      label: t("video-monitoring.camera.fields.name"),
      prop: "name",
      render: "input",
      renderProps: {
        placeholder: t("video-monitoring.camera.placeholder.name"),
      },
    },
    {
      label: t("video-monitoring.camera.fields.type"),
      prop: "type",
      render: () => MaRemoteSelect,
      renderProps: {
        api: getVideoTypeList,
        dataHandle: (response: any) => {
          if (response.code === 200 && response.data && response.data.list) {
            // 过滤type为1的数据（点位类型）
            return response.data.list.map((item: any) => ({
              label: item.name,
              value: item.id,
            }));
          }
          return [];
        },
        placeholder: "请选择摄像头类型",
        clearable: true,
      },
    },
    {
      label: t("video-monitoring.camera.fields.short_name"),
      prop: "short_name",
      render: "input",
      renderProps: {
        placeholder: t("video-monitoring.camera.placeholder.short_name"),
      },
    },
    {
      label: t("video-monitoring.camera.fields.device_code"),
      prop: "device_code",
      render: "input",
      renderProps: {
        placeholder: t("video-monitoring.camera.placeholder.device_code"),
      },
    },
    {
      label: t("video-monitoring.camera.fields.device_serial"),
      prop: "device_serial",
      render: "input",
      renderProps: {
        placeholder: t("video-monitoring.camera.placeholder.device_serial"),
      },
    },
    {
      label: t("video-monitoring.camera.fields.location"),
      prop: "location",
      render: "input",
      renderProps: {
        placeholder: t("video-monitoring.camera.placeholder.location"),
      },
    },
    {
      label: t("video-monitoring.camera.fields.status"),
      prop: "status",
      render: () => MaDictSelect,
      renderProps: {
        placeholder: t("form.pleaseInput", {
          msg: t("video-monitoring.camera.fields.status"),
        }),
        data: [
          { label: t("video-monitoring.camera.status.online"), value: 1 },
          { label: t("video-monitoring.camera.status.offline"), value: 0 },
        ],
        clearable: true,
        multiple: false,
      },
    },
  ];
}
